import cn.mrcode.fd.blog.entity.User;
import org.junit.Test;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.PropertyAccessorFactory;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.UUID;

/**
 * @author : zhuqiang
 * @version : V1.0
 * @date : 2015/12/25 21:40
 */
public class Demo {
    @Test
    public void uuid(){
        String s = UUID.randomUUID().toString().toUpperCase();
        s = s.replace("-","");
        System.out.println(s);
    }
    @Test
    public void beanWrapper(){
        User target = new User();
        BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(target);
        bw.setPropertyValue("name","张三");
        System.out.println(target.getName());
    }

    @Test
    public void val(){
        ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
        Validator validator = factory.getValidator();
//        validator.validateValue()
    }

    @Test
    public void fun1(){
        File file = new File("d:/f.text");
        FileReader fileReader = null;
        try {
            fileReader = new FileReader(file);
            char[] buf = new char[10000];
            int len;
            while ((len = fileReader.read(buf)) > 0){
                System.out.println(new String(buf));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
